﻿using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Zhy.DigitaPlatform.Models
{
    /// <summary>
    /// 组件实体类
    /// </summary>
    public class ThumbModel
    {
        /// <summary>
        /// 组件类型名称
        /// </summary>
        public string Header { get; set; }
        /// <summary>
        /// 组件项集合
        /// </summary>
        public List<ThumbItemModel> Children { get; set; } = new List<ThumbItemModel>();
    }

    /// <summary>
    /// 组件项实体
    /// </summary>
    public class ThumbItemModel
    {
        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }
        /// <summary>
        /// 类型名称或组件名称
        /// </summary>
        public string TargetType { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Header { get; set; }
        /// <summary>
        /// 宽度
        /// </summary>
        public int Width { get; set; }
        /// <summary>
        /// 高度
        /// </summary>
        public int Height { get; set; }

        /// <summary>
        /// 组件的鼠标左键拖动命令
        /// </summary>
        public RelayCommand<object> ThumbCommand { get; set; }
        /// <summary>
        /// 初始化
        /// </summary>
        public ThumbItemModel()
        {
            ThumbCommand = new RelayCommand<object>(DoThunmCommand);
        }

        /// <summary>
        /// 组件的鼠标拖动方法
        /// 当组件触发左键时就会触发的命令方法
        /// </summary>
        /// <param name="obj"></param>
        private void DoThunmCommand(object obj)
        {
            // 启动拖放操作
            // 参数1：页面控件 参数2：拖动项的关联数据 参数3：展示效果
            DragDrop.DoDragDrop(obj as DependencyObject, this, DragDropEffects.Copy);
        }
    }
}
